package test01;

/**
 * @Author czl
 * @Date 2024-04-16
 */
public class Student {
    private String name;
    private String grade;

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getGrade() {
        return grade;
    }

    public void setGrade(String grade) {
        if (!grade.matches("[ABCDE]")){
            throw new RuntimeException("等级只能是A,B,C,D,E");
        }
        this.grade = grade;
    }

    @Override
    public String toString() {
        return "姓名：" + this.name + "   等级：" + this.grade;
    }
}
